﻿using System.Linq;
using Framework.Poco;
using Shell.DomainDot;
using System;

namespace Framework.Domain
{
    /// <summary>
    /// 经销商赠品管理
    /// </summary>
    public class AgencyGiftsContext : DomainDotBase
    {
        public WithAll<Agency> Agencies { get; set; }

        public WithAll<Gift> Gifts { get; set; }

        public void SetGifts(Guid agencyIdentity, string agencyGifts)
        {
            var original = this.Agencies.SingleOrDefault(a => a.Id.Equals(agencyIdentity));
            if (original != null)
            {
                original.Gifts = agencyGifts;
                this.Agencies.Submit();
            }
        }

        public string GetGifts(Guid agencyIdentity)
        {
            var original = this.Agencies.SingleOrDefault(a => a.Id.Equals(agencyIdentity));
            if (original != null)
            {
                return original.Gifts;
            }
            return String.Empty;
        }
    }
}
